import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';

import '../../common/utils/i18n.dart';
import '../../config.dart';
import '../widget/my_scaffold.dart';

class MyPrivacyPolicyPage extends StatefulWidget {
  const MyPrivacyPolicyPage({super.key});

  @override
  _MyPrivacyPolicyPageState createState() => _MyPrivacyPolicyPageState();
}

class _MyPrivacyPolicyPageState extends State<MyPrivacyPolicyPage> {
  Future<String> loadAsset() async {
    var a = await rootBundle.loadString(JmConfig.i18nEnable
        ? I18n.isAppCn
            ? 'assets/doc/PrivacyPolicy.txt'
            : 'assets/doc/PrivacyPolicy_en.txt'
        : 'assets/doc/PrivacyPolicy.txt');
    return a;
  }

  var _result = "";
  dynamic result;

  void loadAssets() async {
    result = await loadAsset();
    //print(result);
    setState(() {
      _result = result.toString();
    });
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    loadAssets();
  }

  @override
  Widget build(BuildContext context) {
    return MyScaffold(
      title: "隐私政策",
      bottomSafeArea: false,
      //appBarBgColor: Jm_Colors.appBarBg,
      body: _result.isNotEmpty
          ? SingleChildScrollView(
              child: Container(
                padding: const EdgeInsets.only(left: 20, right: 20, top: 15),
                child: Column(
                  children: <Widget>[
                    // SelectableText(
                    //   "隐私协议",
                    //   style:
                    //       TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
                    // ),
                    //Gaps.vGap10,
                    SelectableText(
                      _result,
                      style: TextStyle(
                          fontSize: 17,
                          fontWeight: FontWeight.normal,
                          color: JmConfig.defTextStyle.color),
                    ),
                  ],
                ),
              ),
            )
          : const SpinKitThreeBounce(
              color: Colors.black38,
              size: 30,
            ),
    );
  }
}
